﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SdmxMl.UC
{
    public partial class UcVersion : UserControl
    {
        public UcVersion()
        {
            InitializeComponent();
            
        }
        public new bool Enabled
        {
            get
            {
                return numericUpDownMajor.Enabled;
            }
            set
            {
                numericUpDownMajor.Enabled = numericUpDownMinor.Enabled = value;
            }
        }
        public string Version
        {
            get
            {
                return ((int)numericUpDownMajor.Value).ToString() + "." + ((int)numericUpDownMinor.Value).ToString();
            }
            set
            {
                int major, minor;
                string vers = value == null ? "1.0" : value.Trim();
                string[] arr= vers.Split('.');

                if (arr.Length < 1 || int.TryParse(arr[0], out major) == false)
                    major = 1;
                if (arr.Length < 2 || int.TryParse(arr[1], out minor) == false)
                    minor = 0;
                try
                {
                    numericUpDownMajor.Value = major;
                    numericUpDownMinor.Value = minor;
                }
                catch { }
            }
        }
        
    }
}
